package com.scenic.rd_android.design_model.mvp.presenter;

import com.scenic.rd_android.design_model.mvp.contact.AddTaskContact;
import com.scenic.rd_android.design_model.mvp.model.Task;
import com.scenic.rd_android.design_model.mvp.model.data.TaskDataSource;

/**
 * Created by scenic on 16/8/20.
 */
public class AddEditTaskPresenter implements AddTaskContact.Presenter {

    AddTaskContact.View view;
    TaskDataSource dataSource;

    private String mTaskID;

    public AddEditTaskPresenter(String taskID, AddTaskContact.View view, TaskDataSource dataSource) {
        this.view = view;
        this.dataSource = dataSource;
        mTaskID = taskID;

        view.setPresenter(this);
    }

    @Override
    public void saveTask(String title, String content) {
        dataSource.saveTask(new Task(title, content));
        view.showTasksList();
    }

    @Override
    public void start() {
//            dataSource.getTask(mTaskID, new TaskDataSource.GetTaskCallback() {
//                @Override
//                public void onTaskLoad(Task task) {
//                    if (view.isActive()) {
//                        view.setTitle(task.getTitle());
//                        view.setContent(task.getContent());
//                    }
//                }
//
//                @Override
//                public void onDataNotAvailable() {
//                    if (view.isActive()) {
//                        view.showEmptyTaskError();
//                    }
//                }
//            });
    }
}
